<template>
    <div class="cart-list-item">
        <div class="item-seletor">
            <input type="checkbox" @click="changecheck($event,cartList.iid)" v-model="cartList.checked" >
        </div>
        <div class="item-img">
            <img :src="cartList.image" alt="goods_img">
        </div>
        <div class="item-info">
            <div class="item-title">{{cartList.title}}</div>
            <div class="item-desc">{{cartList.desc}}</div>
            <div class="item-bottom">
                <div class="item-price left" >{{cartList.price}}</div>
                <div class="item-count right">x{{cartList.count}}</div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name: 'CartListItem',
    props: {
        cartList: {
				type: Object,
				default() {
					return {}
				}
			}
    },
    components: {
    },
    methods: {
        changecheck(e,id){
            console.log(e.target.checked,id)
            // 修改 vuex中当前商品的选中状态
            this.$store.dispatch('editgoodscheck',{check:e.target.checked,iid:id})
        }
    },
}
</script>

<style scoped>
.cart-list-item {
    width: 100%;
    padding: 5px;
    display: flex;
    align-items: center;
    font-size: 0;
    border-bottom: 2px solid rgba(100, 100, 100, .2);
    
}
.item-seletor{
    
    margin-left: 10px;
    width: 30px;
    height: 30px;
    background-color: #fff;
    border-radius: 50%;
}
.item-seletor input{
    outline: none;
  width: 30px;
  height: 30px;
  background-color: #ffffff;
  border: solid 0px #cccccc;
  -webkit-border-radius: 50%;
  border-radius: 50%;
  font-size: 0.8rem;
  margin: 0;
  padding: 0;
  cursor:pointer;
  -webkit-appearance: none;
  -webkit-user-select: none;
  vertical-align: top;
  background: url("~@/assets/img/cart/uncheck.png") no-repeat;
   background-size: 100% 100%;
}
.item-seletor input:checked{
  background: url("~@/assets/img/cart/checked.png") no-repeat;
  background-size: 100% 100%;
}
.item-img {
    padding: 5px;
}
.item-img img {
    width: 80px;
    height: 100px;
    border-radius: 5px;
    display: block;
}
.item-info {
    display: flex;
    flex-direction: column;
    padding: 5px 10px;
    overflow: hidden;
    font-size: 17px;
    color: #333;
}
.item-info .item-desc {
  font-size: 14px;
  color: #666;
  margin-top: 15px;
}
.item-title,.item-desc{
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.item-bottom {
    
    margin-top: 10px;
}
.item-info .item-price {
    color: deeppink;
    /* font-size: 20px; */
    font-weight: bold;
}

</style>